#ifndef __POLLER_H__
#define __POLLER_H__

#include "Spark/Utils/NonCopyable.h"
#include "Spark/Net/EventLoop.h"

#include <memory>

class Channel;
class Poller : NonCopyable
{
  public:
    virtual ~Poller()
    {
    }
    void assertInLoopThread()
    {
        loop_->assertInLoopThread();
    }
    virtual void poll(int timeoutMs, ChannelList* acctiveChannels) = 0;
    virtual void updateChannel(Channel* ch) = 0;
    virtual void removeChannel(Channel* ch) = 0;

    /**
     * @brief Non-member function to create an instance of Poller
     * It's not allowed to create Poller instance without an EventLoop
     * @param  loop The EventLoop to which this Poller is about to tie
     * @return Pointer to new instance of Poller
     */
    static Poller* newPoller(EventLoop* loop);

  protected:
    explicit Poller(EventLoop* loop) : loop_(loop)
    {
    }
    EventLoop* loop_;
};

#endif  // __POLLER_H__